package com.actor;

//import com.xeditest.xedidraw.GameScreen;
//import com.xeditest.xedidraw.XorSprite;

public class Actor {

	   public static final int STATE_NORMAL = 0;
	    public static final int STATE_JUMPING = 1;
	    public static final int STATE_RUNNING = 2;

	    public static final float SPEED = .3f;
	    public static final int GRAVITY = 1;//.002f;
	    public int _mposx;
	    public int _mposy;
	    int _veloX;
	    int _veloY;
	    
	    //XorSprite animation;
	    
	    private int floorY;
	    private int state;

	    public Actor() {
	     
	        state = STATE_NORMAL;
	    }
	    //public Actor(XorSprite anim) {
		     //animation =  anim;
	         //state = STATE_JUMPING;
	         //animation.setAnim(2);
	   // }

	    public void setPos(int x, int y)
	    {
	    	_mposx= x;
	    	_mposy = y;
	    }

	    /**
	        Gets the state of the Player (either STATE_NORMAL or
	        STATE_JUMPING);
	    */
	    public int getState() {
	        return state;
	    }


	    /**
	        Sets the state of the Player (either STATE_NORMAL or
	        STATE_JUMPING);
	    */
	    public void setState(int state) {
	        this.state = state;
	        if(STATE_RUNNING == state)
	        {
	        	_veloX= -1;
	        	 //animation.setAnim(1);
	        }
	        else if(STATE_RUNNING == state)
	        {
	        	 //animation.setAnim(2);
	        }
	        	
	    }


	    /**
	        Sets the location of "floor", where the Player starts
	        and lands after jumping.
	    */
	    public void setFloorY(int floorY) {
	        this.floorY = floorY;
	  
	    }


	    /**
	        Causes the Player to jump
	    */
	    public void jump() {
	        setVelocityY(-1);
	        state = STATE_JUMPING;
	    }
	    
	    public void setVelocityX(int x)
	    {
	    	_veloX = x;
	    }
	    public void setVelocityY(int y)
	    {
	    	_veloY = y;
	    }
	    public int getVelocityX()
	    {
	    	return _veloX ;
	    }
	    public int getVelocityY()
	    {
	    	return _veloY ;
	    }

	    /**
	        Updates the player's position and animation. Also, sets the
	        Player's state to NORMAL if a jumping Player landed on
	        the floor.
	    */
	    public void update(long elapsedTime) {
	    	
	        // set vertical velocity (gravity effect)
	        if (getState() == STATE_JUMPING) {
	            setVelocityY(1);//getVelocityY() + (int)(GRAVITY * elapsedTime));
	        }

	        _mposx -= _veloX ;//* elapsedTime;
	        _mposy -= _veloY ;//* elapsedTime;

	        
	        //animation.update(elapsedTime);

	        // check if player landed on floor
	        if (getState() == STATE_JUMPING && _mposy <= floorY) {
	           // setVelocityY(0);
	            //_mposy = floorY;
	           // setState(STATE_NORMAL);
	        }

	    }
	    
	    public void draw()
	    {
	    	//animation.setPos(_mposx - GameScreen.tiledMapHelper.getCameraX(), _mposy - GameScreen.tiledMapHelper.getCameraY());
	    	//animation.render();
	    }
	    
	    public int getHeight()
	    {
	    	return 30;
	    }
	    public int getWidth()
	    {
	    	return 35;
	    }

	
}
